package com.bear.atlassianmcp.confluence.model;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

import java.util.Map;

/**
 * Confluence标签数据模型
 * 对应Confluence REST API返回的Label对象
 */
@JsonIgnoreProperties(ignoreUnknown = true)
public class ConfluenceLabel {

    private String id;
    private String name;
    private String prefix;
    
    @JsonProperty("_links")
    private Map<String, Object> links;

    /**
     * 获取标签的Web URL
     */
    public String getWebUrl() {
        if (links != null && links.containsKey("webui")) {
            return (String) links.get("webui");
        }
        return null;
    }

    /**
     * 格式化为AI友好的文本描述
     */
    public String toFormattedString() {
        StringBuilder sb = new StringBuilder();
        sb.append("🏷️ 标签: ").append(name).append("\n");
        
        if (id != null) {
            sb.append("🆔 ID: ").append(id).append("\n");
        }
        
        if (prefix != null && !prefix.trim().isEmpty()) {
            sb.append("📂 前缀: ").append(prefix).append("\n");
        }
        
        String webUrl = getWebUrl();
        if (webUrl != null) {
            sb.append("🔗 链接: ").append(webUrl).append("\n");
        }
        
        return sb.toString();
    }

    // Getters and Setters
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPrefix() {
        return prefix;
    }

    public void setPrefix(String prefix) {
        this.prefix = prefix;
    }

    public Map<String, Object> getLinks() {
        return links;
    }

    public void setLinks(Map<String, Object> links) {
        this.links = links;
    }
}
